#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2005;
int n,m,q,pre[3][N][N];
char s[N][N];
int sum(int k,int x,int y,int xx,int yy)
{
	if(x>xx||y>yy) return 0;
	return pre[k][xx][yy]-pre[k][xx][y-1]-pre[k][x-1][yy]+pre[k][x-1][y-1]; 
}
int main()
{
	freopen("unicom.in","r",stdin);
	freopen("unicom.out","w",stdout);
    scanf("%d%d%d",&n,&m,&q);
    for(int a=1;a<=n;a++) scanf("%s",s[a]+1);
    for(int a=2;a<=n;a++)
    {
    	for(int b=1;b<=m;b++)
    	{
    		pre[0][a][b]=pre[0][a-1][b]+pre[0][a][b-1]-pre[0][a-1][b-1];
    		if(s[a-1][b]=='1'&&s[a][b]=='1') pre[0][a][b]++;
		}
	}
	for(int a=1;a<=n;a++)
    {
    	for(int b=2;b<=m;b++)
    	{
    		pre[1][a][b]=pre[1][a-1][b]+pre[1][a][b-1]-pre[1][a-1][b-1];
    		if(s[a][b-1]=='1'&&s[a][b]=='1') pre[1][a][b]++;
		}
	}
	for(int a=1;a<=n;a++)
	{
		for(int b=1;b<=m;b++)
		{
			pre[2][a][b]=pre[2][a-1][b]+pre[2][a][b-1]-pre[2][a-1][b-1];
			if(s[a][b]=='1') pre[2][a][b]++;
		}
	}
	while(q--)
	{
		int x,y,xx,yy;
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		printf("%d\n",-sum(0,x+1,y,xx,yy)-sum(1,x,y+1,xx,yy)+sum(2,x,y,xx,yy));
	}
}
